<?php

Yii::import('application.modules.file.models.File');
Yii::import('application.modules.file.models.FileCategories');

class FileController extends Controller {

    /**
     * Lists all models.
     */
    public $layout = '//layouts/column2';

    public function init() {
        Yii::app()->theme = 'home';
    }

    public function actionView() {
        $model = FileCategories::model()->findByPk($_GET['id']);
        $criteria = new CDbCriteria(array(
            'order' => 'id DESC',
        ));

        $criteria->compare('category_id', $_GET['id']);
        $criteria->compare('status', 1);
        $count = File::model()->count($criteria);
        $pages = new CPagination($count);
        $pages->pageSize = 10;
        $pages->applyLimit($criteria);
        $file = File::model()->findAll($criteria);
        $this->render('view', array('model' => $model, 'file' => $file, 'pages' => $pages));
    }

}